package com.tanhua.api.db;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.domain.db.Announcement;
import com.tanhua.domain.vo.PageBeanVo;
import com.tanhua.mapper.AnnouncementMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class AnnouncementApiImpl implements AnnouncementApi {

    @Autowired
    private AnnouncementMapper announcementMapper;

    @Override
    public PageBeanVo findByPage(Integer pageNum, Integer pageSize) {
        // 1、创建分页对象
        IPage<Announcement> page = new Page<>(pageNum, pageSize);
        // 2、实现分页查询
        QueryWrapper<Announcement> qw = new QueryWrapper<>();
        page = announcementMapper.selectPage(page, qw);
        return new PageBeanVo(pageNum, pageSize, page.getTotal(), page.getRecords());
    }
}
